var strategies={
			isNoEmpty:function(value,errorMsg){
				if(value==='')
				{
					return errorMsg;
				}
			},
			minLength:function(value,length,errorMsg){
				if(value.length<parseInt(length)){
					return errorMsg;
				}
			},
			reg:function(value,reg,errorMsg){
				var regExp = eval(reg)
				if(!regExp.test(value)){
					return errorMsg;
				}
			}
		}

		var Vaildator=function(){
			this.cache=[];//校验规则列表
		}

		Vaildator.prototype.add=function(dom,rules,errorMsg){
			var that=this;
			for (var i = 0,rule; i <rules.length,rule=rules[i]; i++) {
				//闭包，this指向全局
				(function(rule){
					var strategyAry=rule.strategy.split(':');
					var errorMsg=rule.errorMsg;
					that.cache.push(function(){
						var strategy=strategyAry.shift();
						strategyAry.unshift(dom.value);
						strategyAry.push(errorMsg);
						return strategies[strategy].apply(dom,strategyAry);
					})

				})(rule)
			}


		}

		Vaildator.prototype.start=function(){
			for(let i=0;i<this.cache.length;i++){
				let vaildatorFun=this.cache[i];
				var msg=vaildatorFun();
				if(msg){
					return msg;
				}
			}
		}